package com.atguigu.yygh.common.component;

import com.atguigu.yygh.common.enums.QueueEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 孔德成
 * @slogan 致敬大师，致敬未来的你
 * @date 2021/9/14 7:19 下午
 * @desc 给短信队列发消息
 */
@Component
@Slf4j
public class MsmSender {
    private final AmqpTemplate amqpTemplate;

    public MsmSender(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    public void sendMessage(Object message) {
        //给队列发送消息
        amqpTemplate.convertAndSend(QueueEnum.QUEUE_MSM_SUCCESS.getExchange(), QueueEnum.QUEUE_MSM_SUCCESS.getRouteKey(), message);
        log.info("send message to msm queue:{}", message);
    }

    public void sendToPatient(Object message) {
        //给就诊短信队列发送消息
        amqpTemplate.convertAndSend(QueueEnum.QUEUE_MSM_PATIENT.getExchange(), QueueEnum.QUEUE_MSM_PATIENT.getRouteKey(), message);
        log.info("send message to patient:{}", message);
    }
}
